﻿using Shop.StoreGatewayModular.ExtendService;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Helper.Area;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Interface;

namespace Shop.StoreGatewayModular
{
    public class ShopStoreApiModular : BasicApiModular
    {
        public ShopStoreApiModular () : base("ShopStoreApi_Gateway")
        {
        }
        protected override void Init ()
        {
            EnumService.Load();
            AreaHelper.LoadArea();
        }
        protected override void Load ( IHttpGatewayOption option, IModularConfig config )
        {
            config.ApiRouteFormat = "/shop/{controller}/{name}";
            option.IocBuffer.SetDefLifetimeType(( body ) =>
            {
                if ( body.To.FullName.StartsWith("Shop.StoreGatewayModular.Interface.") )
                {
                    body.SetLifetimeType(ClassLifetimeType.SingleInstance);
                }
            });
        }
    }
}